﻿@using SCMS.Resources
@model SCMS.UI.Models.PPModel
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Resources_frank.Global_String_ProcurementPlan :: @Model.EntityPP.RefNumber</h3></div>   
    @if (UserContext.HasPermission(StandardPermissionProvider.ProcurementPlanManage))
    {
        <center>  
            @Ajax.ActionLink(Resources_frank.ProcurementPlan_CreatePPStep2_EditPP, "EditPP", new { id = Model.EntityPP.Id }, new AjaxOptions
       {
           UpdateTargetId = "ppDiv",
           LoadingElementId = "loading"
       }) | 
            @Ajax.ActionLink(Resources_frank.ProcurementPlan_ViewPP_DeletePP, "DeletePP", new { id = Model.EntityPP.Id }, new AjaxOptions
       {
           UpdateTargetId = "ppDiv",
           LoadingElementId = "loading",
           Confirm = Resources_frank.ProcurementPlan_ViewPP_ConfirmDelete
       }) 
        </center>
    }
    else
    { 
        <br />
    }
    <table width="98%" align="center" cellpadding="0" class="cardTable">
        <tr>
            <th align="center" width="33%">
                @Resources_frank.OrderRequest_AddPPItems2OR_OfficePreparing
            </th>
            <th align="center" width="33%">
                @Resources_frank.Global_String_PreparedByName
            </th>
            <th align="center" colspan="2">
                @Resources_frank.Global_String_Date
            </th>
        </tr>
        <tr>
            <td align="center" valign="top">
                @Model.EntityPP.CountrySubOffice.Name
            </td>
            <td align="center" valign="top">
                @Model.EntityPP.Staff.Person.FirstName
                &nbsp;
                @Model.EntityPP.Staff.Person.OtherNames
            </td>
            <td align="center" colspan="2">
                @Model.EntityPP.PreparedOn.ToString("dd/MM/yyyy")
            </td>
        </tr>
        <tr>
            <th align="center">
                @Resources_frank.Budget_CategoryList_ProjectNo
            </th>
            <th align="center">
                @Resources_frank.Global_String_PreparedByTitle
            </th>
            <th align="center" width="17%">
                @Resources_frank.ProcurementPlan_CreatePPStep2_ProjectStartDate
            </th>
            <th align="center" width="17%">
                @Resources_frank.ProcurementPlan_CreatePPStep2_ProjectEndDate
            </th>
        </tr>
        <tr>
            <td align="center" title="@Model.EntityPP.ProjectDonor.Project.Name">
                @Model.EntityPP.ProjectDonor.ProjectNumber
            </td>
            <td align="center">
                @Model.EntityPP.Staff.Designation.Name
            </td>
            <td align="center">
                @Model.EntityPP.ProjectDonor.StartDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.EntityPP.ProjectDonor.EndDate.ToString("dd/MM/yyyy")
            </td>
        </tr>
    </table> 
    <br />
    <div id="ppItems">
        &nbsp;&nbsp;&nbsp;
        @Ajax.ActionLink(Resources_frank.ProcurementPlan_PPItemsList_AllItems, "ViewPPItems", new { id = Model.EntityPP.Id, type = "all" }, new AjaxOptions
   {
       UpdateTargetId = "ppItems",
       LoadingElementId = "loading",
       OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
   }, new { style = "font-weight: bold;" }) | 
        @Ajax.ActionLink(Resources_frank.ProcurementPlan_PPItemsList_ActivieItems, "ViewPPItems", new { id = Model.EntityPP.Id, type = "active" }, new AjaxOptions
   {
       UpdateTargetId = "ppItems",
       LoadingElementId = "loading",
       OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
   }) | 
        @Ajax.ActionLink(Resources_frank.ProcurementPlan_PPItemsList_InactiveItems, "ViewPPItems", new { id = Model.EntityPP.Id, type = "inactive" }, new AjaxOptions
   {
       UpdateTargetId = "ppItems",
       LoadingElementId = "loading",
       OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
   }) |
        @Ajax.ActionLink(Resources_frank.ProcurementPlan_PPItemsList_RemovedItems, "ViewPPItems", new { id = Model.EntityPP.Id, type = "removed" }, new AjaxOptions
   {
       UpdateTargetId = "ppItems",
       LoadingElementId = "loading",
       OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
   })
        <br /><br />
        @if (Model.PPItems.Count > 0)
        {
            <div id="tablewrapper">
                <div id="tableheader">
                    <div class="search">
                        <b>@Resources_frank.Global_String_SearchBy:</b><br />
                        <select id="columns" onchange="sorter.search('query')">
                        </select>
                        <input type="text" id="query" onkeyup="sorter.search('query')" />
                    </div>
                    <span class="details">
                        <div>
                            @Resources_frank.Global_String_Records <span id="startrecord"></span>-<span id="endrecord"></span> @Resources_frank.Global_String_Of <span id="totalrecords">
                            </span>
                        </div>
                    </span>
                </div>
                <br />
                <br />
                <br />
                <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable">
                    <thead>
                        <tr>
                            <th><h3>@Resources_frank.ProcurementPlan_PPItemsList_AddedToOR</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddPPItems2OR_DescriptionOfGoods</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddPPItems2OR_TechincalSpecification</h3></th>
                            <th><h3>@Resources_morgan.Global_String_Unit</h3></th>
                            <th><h3>@Resources_frank.Global_String_Qty</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddItemInEditMode_EstUnitPrice</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddItemInEditMode_EstTotalPrice</h3></th>
                            <th><h3>@Resources_frank.Global_String_Currency</h3></th>
                            <th><h3>@Resources_frank.Global_String_BL</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddPPItems2OR_RequiredDeliveryLocation</h3></th>
                            <th><h3>@Resources_frank.OrderRequest_AddPPItems2OR_RequiredDeliveryDate</h3></th>
                        </tr>
                    </thead>
                    <tbody>
                        @{string title = "";}
                        @foreach (var item in Model.PPItems)
                        {
                            if (item.EntityPPItem.AddedToOR)
                            {
                                title = item.EntityPPItem.OrderRequestItem.OrderRequest.RefNumber;
                            }
                            else
                            {
                                title = "";
                            }
                            if (item.EntityPPItem.IsRemoved)
                            {
                                <tr class="gridodd" title="@Resources_frank.Global_String_Removed">     
                                    <td align="center">@Html.CheckBoxFor(m => item.EntityPPItem.AddedToOR, new { disabled = "disabled" })</td>     
                                    <td><strike>@item.EntityPPItem.Item.Name</strike></td>
                                    <td><strike>@item.EntityPPItem.ItemDescription</strike></td>
                                    <td><strike>@item.EntityPPItem.Item.UnitOfMeasure.Code</strike></td>
                                    <td align="center"><strike>@item.EntityPPItem.Quantity</strike></td>
                                    <td align="right"><strike>@item.EntityPPItem.UnitCost.ToString("#,##0.00")</strike></td>
                                    <td align="right"><strike>@item.EntityPPItem.TotalCost.ToString("#,##0.00")</strike></td>
                                    <td align="center"><strike>@item.EntityPPItem.Currency.ShortName</strike></td>
                                    <td align="center"><strike>@item.EntityPPItem.ProjectBudget.LineNumber</strike></td>
                                    <td><strike>@item.EntityPPItem.Location.Name</strike></td>
                                    <td align="right"><strike>@item.EntityPPItem.RequiredDeliveryDate.ToString("dd/MM/yyyy")</strike></td>
                                </tr>
                            }
                            else
                            { 
                                <tr class="gridodd" title="@string.Format(Resources_frank.ProcurementPlan_PPItemsList_AddedTo, title)">     
                                    <td align="center">@Html.CheckBoxFor(m => item.EntityPPItem.AddedToOR, new { disabled = "disabled" })</td>     
                                    <td>@item.EntityPPItem.Item.Name</td>
                                    <td>@item.EntityPPItem.ItemDescription</td>
                                    <td>@item.EntityPPItem.Item.UnitOfMeasure.Code</td>
                                    <td align="center">@item.EntityPPItem.Quantity</td>
                                    <td align="right">@item.EntityPPItem.UnitCost.ToString("#,##0.00")</td>
                                    <td align="right">@item.EntityPPItem.TotalCost.ToString("#,##0.00")</td>
                                    <td align="center">@item.EntityPPItem.Currency.ShortName</td>
                                    <td align="center">@item.EntityPPItem.ProjectBudget.LineNumber</td>
                                    <td>@item.EntityPPItem.Location.Name</td>
                                    <td align="right">@item.EntityPPItem.RequiredDeliveryDate.ToString("dd/MM/yyyy")</td>
                                </tr>
                            }
                        }
                    </tbody>
                </table>
                <div id="tablefooter">
                    <div id="tablenav">
                        <div>
                            <img src="../../Content/images/pager/first.gif" width="16" height="16" alt="@Resources_frank.Global_String_FirstPage"
                                onclick="sorter.move(-1,true)" />
                            <img src="../../Content/images/pager/previous.gif" width="16" height="16" alt="@Resources_frank.Global_String_PreviousPage"
                                onclick="sorter.move(-1)" />
                            <img src="../../Content/images/pager/next.gif" width="16" height="16" alt="@Resources_frank.Global_String_NextPage"
                                onclick="sorter.move(1)" />
                            <img src="../../Content/images/pager/last.gif" width="16" height="16" alt="@Resources_frank.Global_String_LastPage"
                                onclick="sorter.move(1,true)" />
                        </div>
                        <div>
                            <select id="pagedropdown">
                            </select>
                        </div>
                        <div>
                            <a href="javascript:sorter.showall()">@Resources_frank.Global_String_ViewAll</a>
                        </div>
                    </div>
                    <div id="tablelocation">
                        <div>
                            <select onchange="sorter.size(this.value)">
                                <option value="5">5</option>
                                <option value="10">10</option>
                                <option value="20" selected="selected">20</option>
                                <option value="50">50</option>
                                <option value="100">100</option>
                            </select>
                            <span>@Resources_frank.Global_String_EntriesPerPage</span>
                        </div>
                        <div class="page">
                            @Resources_frank.Global_String_Page <span id="currentpage"></span>@Resources_frank.Global_String_Of <span id="totalpages"></span>
                        </div>
                    </div>
                </div>
            </div>
        }
        else
        { 
            <center style=" font-style: italic">@Resources_frank.ProcurementPlan_ViewPP_NoItems</center>
        }
    </div>
    <br />
</div>
         


